package cn.gson.crm.control.dept;

import java.sql.SQLException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.DeptDao;
/**
 * 部门删除
 * */
@WebServlet("/dept/delete")
public class DeptDeleteServlet extends BaseServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private DeptDao daptDao = new DeptDao(); 
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		// TODO Auto-generated method stub
				String[] ids = request.getParameterValues("id");
				String deptNameStr = "";
				for (String id : ids) {
					try {
							daptDao.deleteDeptById(id);
						}
					 catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				
				request.getSession().setAttribute("deptNameStr", deptNameStr);
				response.sendRedirect(request.getContextPath() + "/dept/manager");
			}
	}


